package com.samoiloff.net {
	import flash.events.ProgressEvent;
	import flash.events.Event;
	import flash.events.IOErrorEvent;
	import flash.events.SecurityErrorEvent;
	import flash.net.URLLoader;
	import flash.net.URLRequest;

	/**
	 * @author Samoiloff
	 */
	public class CustomURLLoader extends URLLoader {
		
		public function CustomURLLoader(request: URLRequest, onComplete:Function, onError:Function, onProgress:Function = null) {
			super.load(request);
			addEventListener(Event.COMPLETE, onComplete);
			addEventListener(IOErrorEvent.IO_ERROR, onError);
			addEventListener(SecurityErrorEvent.SECURITY_ERROR, onError);
			if (Boolean(onProgress)) {
				addEventListener(ProgressEvent.PROGRESS, onProgress);
			}
		}
		
		override public function load(request: URLRequest): void {
			throw new Error("Use constructor() instead");
		}
		
	}
}
